import Vue from 'vue';
import Router from 'vue-router';
import Layout from '@/layout'
import beforeEach from './beforeEach'

Vue.use(Router);

export const defaultRoutes = [
	{
		path: '/index',
		icon: 'el-icon-s-home',
		component: resolve => require(['@/views/index'], resolve),
		meta: {
			title: '首页',
			role: []
		}
	},
	{
		path: '/log',
		icon: 'el-icon-s-order',
		component: resolve => require(['@/views/log'], resolve),
		meta: {
			title: '系统日志',
			role: []
		}
	},
]

const router = new Router({
	routes: [{
			path: '/login',
			component: resolve => require(['@/views/login'], resolve)
		},
		{
			path: '/',
			component: Layout,
			icon: 'el-icon-s-custom',
			redirect: '/index',
			children: defaultRoutes
		},
		{
			path: '/404',
			component: resolve => require(['@/views/error/404.vue'], resolve),
			// meta: { title: '404' }
		},
		{
			path: '/403',
			component: resolve => require(['@/views/error/403.vue'], resolve),
			// meta: { title: '403' }
		},
		{
			path: '*',
			redirect: '/404'
		}
	]
})

router.beforeEach(beforeEach)

export default router
